package com.atguigu.srb.core.controller.api;


import com.atguigu.srb.base.result.R;
import com.atguigu.srb.core.pojo.vo.BorrowerVO;
import com.atguigu.srb.core.service.BorrowerService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 借款人 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-01-04
 */
@RestController
@RequestMapping("/api/core/borrower")
public class ApiBorrowerController {
    @Resource
    BorrowerService borrowerService;

    @ApiOperation("查询借款人审核状态")
    @GetMapping("/auth/borrowerStatus")
    public R getBorrowerStatus(@RequestHeader(value = "token" , required = false)String token){
        Integer status = borrowerService.getBorrowerStatus(token);
        return R.ok().data("status" , status);
    }

    @ApiOperation("保存借款人认证信息")
    @PostMapping("/auth/saveBorrower")
    public R saveBorrower(@RequestBody BorrowerVO borrowerVO,
                          @RequestHeader(value = "token" , required = false)String token){//前端提交的数据需要拆分存到多张表中 需要自定义vo类接收数据
        borrowerService.saveBorrower(borrowerVO,token);

        return R.ok();
    }

}

